﻿using System.Reflection;
using NUnit.Core;

namespace Rauchy.Oapt
{
    public class OneAssertTestMethod : NUnitTestMethod
    {
        #region Fields (1) 

        private readonly int assertToRun;

        #endregion Fields 

        #region Constructors (1) 

        public OneAssertTestMethod(MethodInfo method, string testName, int assertToRun) : base(method)
        {
            this.assertToRun = assertToRun;
            TestName.Name = testName;
        }

        #endregion Constructors 

        #region Methods (1) 

        // Public Methods (1) 

        public override void RunTestMethod(TestResult testResult)
        {
            AssertOne.WhatToRun = assertToRun;

            try
            {
                base.RunTestMethod(testResult);
            }
            finally
            {
                AssertOne.Current = 0;
            }
        }

        #endregion Methods 
    }
}